#ifndef OUTTIME_DELAY_H
#define OUTTIME_DELAY_H
#include "common_conf.h"
#include <time.h>
#include <stdint.h>
#define delay_ms(x)     usleep(x*1000)   
#define delay_s(x)      sleep(x)   

int get_clocktime(struct timespec *ttime);

typedef struct _OutTime {


	struct timespec tStartTime;
	uint64_t u64ms_Timeout;
	uint8_t  u8MaxTimeoutNum;   //最大超时次数 用来判断u8Count是否超过这个最大值
	uint8_t  u8Count; 		   //超时次数计数 
	
}T_OutTime , *PT_OutTime;

enum _outtime_delay_return_val_e{

    OUTTIME_DELAY_RETURN_VAL_OUTTIME        = 0,
    OUTTIME_DELAY_RETURN_VAL_WAIT_OUTTIME   = 1,
    OUTTIME_DELAY_RETURN_VAL_NO_SET_OUTTIME = 2,
    OUTTIME_DELAY_RETURN_VAL_ERR            = 3,
};

enum _outtime_delay_return_val_e  is_timeout(struct timespec ttime ,  uint64_t u64Timeout_ms);
enum _outtime_delay_return_val_e remaining_timeout_val(struct timespec ttime ,  uint64_t u64Timeout_ms, uint64_t* pu64out_remaining_time_val);
int set_outtime(PT_OutTime ptOutTime , struct timespec tStartTime , uint64_t u64OutTime , uint8_t u8MaxTimeoutNum );
uint64_t get_difftime(PT_OutTime ptOutTime );
void clear_outtime(PT_OutTime ptOutTime);
#endif